package com.example.demo.mapper;


import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface UserAuthorityMapper {


    @Insert("insert user_authority_table VALUES (0,#{uId},#{aId})")
    public int insertUserAuthority(Integer uId, Integer aId);

    @Select("select ua.id\n" +
            "from user_table u,\n" +
            "     user_authority_table ua,\n" +
            "     authority_table a\n" +
            "where u.id = ua.u_id\n" +
            "  and a.id = ua.a_id\n" +
            "  and u.id = #{id}")
    public Integer getUserAuthorityIdById(Integer id);

    @Update("update user_authority_table\n" +
            "set a_id=#{aId}\n" +
            "where id=#{id}")
    public int updateUserAuthorityById(Integer aId,Integer id);

    @Delete("delete\n" +
            "from user_authority_table\n" +
            "where id = #{id}")
    public int deleteUserAuthorityById(Integer id);
}
